package nguyenquangminh.minigame;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class Egg {
	private BufferedImage image;
	protected static final int WIDTH = 30;
	protected static final int HEIGHT = 40;
	private int x = 0;
	private int y = 0;
	private static int dy = 1;
	private Game game;
	public boolean isVisible;
	
	// Constructor
	public Egg(int x, int y) {
		URL imageUrl = this.getClass().getResource("/images/egg.png");
		try {
			image = ImageIO.read(imageUrl);
		} catch (IOException e) {
			e.printStackTrace();
		}
		this.x = x;
		this.y = y;
		isVisible = true;
	}
	// Move method
	public void move() {
		y = y + dy;
		if (y > game.S_HEIGHT)
			isVisible = false;
	}
	// Get X coordinates
	public int getX() {
		return x;
	}
	// Get Y coordinates
	public int getY() {
		return y;
	}
	// Get speed 
	public int getSpeed() {
		return dy;
	}
	// Get Image
	public Image getImage() {
		return image;
	}
	
	// Set speed move
	public void setSpeed(int speed) {
		dy = speed;
	}
	
	// Paint egg
	public void paint(Graphics2D g2d) {
		g2d.drawImage(image, x, y, WIDTH, HEIGHT, null);
	}
	
	// Rectangle egg
	public Rectangle getBounds() {
	    return new Rectangle(x, y, WIDTH, HEIGHT);
	}
} // End Egg class
